﻿import QtQuick 2.10
import QtQuick.Window 2.10

import "qrc:/Canvas1/qml/RES/"

Window {
    visible: true
    width: 640
    height: 480
    title: qsTr("Hello World")

    property var _list:[0,0,50,100,-50,0,0]

    Component.onCompleted: {
    }

    Rectangle{
        anchors.fill: parent
        color: "black"
    }

    Image{
        id: itemCanvas
        width: 500
        height: 400
        anchors.centerIn: parent
//        color: Qt.rgba(15/255,19/255,118/255, 0.8)
        source: "qrc:/bg.png"

        transform: Rotation{
            axis.x: 0
            axis.y: 1
            axis.z: 0

            origin.x: itemCanvas.width/2
            origin.y: itemCanvas.height/2

            angle: 30
        }

        Canvas {
            id: canvas
            anchors.fill: parent

            property color color: "#FF0000"
            property real lastX: 0
            property real lastY: 0
            property real qx
            property real qy    //控制点

            onPaint: {
                //0,0 在左上角
                var ctx = getContext('2d')

                ctx.clearRect(0, 0, canvas.width, canvas.height)

                //基线
                ctx.lineWidth = 1.0
                ctx.strokeStyle = "#bdfcff"
                ctx.beginPath()
                ctx.moveTo(100-20, canvas.height - 150)
                ctx.lineTo(300+20, canvas.height - 150)
                ctx.stroke()

                ctx.lineWidth = 5.0
                ctx.strokeStyle = "#bdfcff"
                ctx.lineJoin = "miter"   //miter, bevel, round
                ctx.lineCap = "butt"        //butt,round,square
                ctx.beginPath()
                for(var i=0; i<_list.length; i++){

                    var x1 = i*20 + 100
                    var y1 = canvas.height - _list[i] - 150

                    if(i == 0){
                        ctx.moveTo(x1, y1)
                    }
                    else if(i == _list.length-1){
                        ctx.lineTo(x1, y1)
                        ctx.stroke()
                    }
                    else{
                       ctx.lineTo(x1, y1)
                    }

                    lastX = x1
                    lastY = y1

                }
            }
        }

    }

    Image{
        anchors.left: parent.right
        anchors.leftMargin: -40
        anchors.verticalCenter: parent.verticalCenter
        source: "qrc:/timg.png"
    }

    Image{
        fillMode: Image.Stretch
        width: 300
        height: 200
        anchors.right: parent.right
        anchors.bottom: parent.bottom
        anchors.bottomMargin: -80
        source: "qrc:/webwxgetmsgimg.png"
    }
}
